package com.kylinhunter.ch.plugin.knowledgebase.dao.ex;

import java.util.List;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
 
import com.khplatformtool.service.page.KHPPage;
import com.kylinhunter.ch.plugin.knowledgebase.dao.Chcode;
import com.kylinhunter.ch.plugin.knowledgebase.dao.ChcodeDAO;

/**
 * A data access object (DAO) providing persistence and search support for
 * Chcode entities. Transaction control of the save(), update() and delete()
 * operations can directly support Spring container-managed transactions or they
 * can be augmented to handle user-managed Spring transactions. Each of these
 * methods provides additional information for how to configure it for the
 * desired type of transaction control.
 * 
 * @see com.kylinhunter.ch.plugin.knowledgebase.dao.Chcode
 * @author MyEclipse Persistence Tools
 */

public class ChcodeDAOEX extends ChcodeDAO  implements KHPPage{
	private static final Log log = LogFactory.getLog(ChcodeDAOEX.class);
	@Override
	public int getCount(Object obj) {
		// TODO Auto-generated method stub
		Chcode chcode=(Chcode) obj;
		List userList = null;
		String sql = "select count(chcode.id) from Chcode as chcode";
		String sqlWhere=createQueryUserInfoSqlWhere( chcode);

		if (!sqlWhere.equals("")) {
			sql += " where  1=1   "+sqlWhere;
		}

		userList = getHibernateTemplate().find(sql);

		if (userList == null) {
			return 0;
		}
		return ((Long) userList.get(0)).intValue();
	}
	@Override
	public List findAllByPage(int pageNo, int user_page_size,Object obj) {
		// TODO Auto-generated method stub
		Chcode module=(Chcode) obj;
		if (pageNo < 1) {
			pageNo=1;
		}
		int offset = (pageNo - 1) * user_page_size;
		String sql = "from Module as module";
		String sqlWhere=createQueryUserInfoSqlWhere(module);
		if (!sqlWhere.equals("")) {
			sql += " where 1=1   "+sqlWhere;
		}
		List l=findByPage(sql, offset, user_page_size);
		return l;
	}
	@Override
	public String createQueryUserInfoSqlWhere( Object obj ) {
		Chcode module=(Chcode) obj;
		String sqlWhere = "";	
		  
		return sqlWhere;

	}
}